import React, { useState, useEffect } from 'react';
import request from '@/utils/request';

export function useGetdata(id) {
    const [dishes, setDishes] = useState({});

    useEffect(() => {
        request.get('/menu/' + id).then(({ data }) => {

            if (data.code === 200) {
                let newData = data.data;
                if (newData.online === 1) {
                    newData.online = true;
                }else if(newData.online === 0){
                    newData.online = false;
                }

                setDishes(newData);
            }
        })
    }, [])


    // console.log(dishes);

    return dishes

    // console.log(dishes);

}
